import {CHANGE_MSG} from '../actionTypes'

let initState = {
    msg:'hello zhou',
    list:[],
   
}

//action的作用，给reducer一个改变数据的信号
//你要改变哪个变量？
//你改的结果是什么？

export default function reducer(state=initState,action){
    switch(action.type){
        case CHANGE_MSG:
        console.log('收到了',action);
        let newState = JSON.parse(JSON.stringify(state))
        newState.msg = action.payload
        //改变msg
        //state.msg= action.payload
        return newState
        
        default:
            return state
    }
}